axios.defaults.baseURL = 'http://api-breakingnews-web.itheima.net'
// 请求拦截器
axios.interceptors.request.use(config => {
    if(config.url.indexOf('/my')!== -1){
        config.headers.Authorization = localStorage.getItem('token')
    }
    return config;
}, error => {
    return Promise.reject(error);
});
// 响应拦截器
axios.interceptors.response.use(response => {
    if(
        response.data.status===1&&
        response.data.message==='身份认证失败！'
    ){
        localStorage.removeItem(('token'))
        location.href='/login.html'
    }
// Do something before response is sent
return response;
},error => {
// Do something with response error
return Promise.reject(error);
});